﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormsApp1
{
    public partial class Form2 : Form
    {
        private Hid_Device_Info select = new Hid_Device_Info();
        public Form2()
        {
            InitializeComponent();
        }

        public void set_list_source(List<Hid_Device_Info> lists)
        {
            listView1.Items.Clear();
            foreach (Hid_Device_Info info in lists)
            {
                ListViewItem item = new ListViewItem();
                item.Text = info.VID.PadLeft(4, '0');
                //item.SubItems.Add(info.VID.ToString("X").PadLeft(4, '0'));
                item.SubItems.Add(info.PID.PadLeft(4, '0'));
                item.SubItems.Add(info.PATH);
                listView1.Items.Add(item);
            }
            listView1.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
        }

        public Hid_Device_Info get_select_device_info()
        {
            return select;
        }

        private void Event_list_view_select(object sender, EventArgs e)
        {
            select.VID = listView1.SelectedItems[0].Text;
            select.PID = listView1.SelectedItems[0].SubItems[1].Text;
            select.PATH = listView1.SelectedItems[0].SubItems[2].Text;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
    }

}
